var timer1 = null;
function mWarns(a) {
    clearInterval(timer1);
    $("[alert]").show().children("[alertLayer]").addClass("bounceUp");
    timer1 = setInterval(function() {
        $("[alert]").hide().children("[alertLayer]").removeClass("bounceUp")
    },
    1500);
    $("[alertlayer]").html(a)
}
var TouchSlide = function(a) {
    a = a || {};
    var b = {
        slideCell: a.slideCell || "#touchSlide",
        titCell: a.titCell || ".hd li",
        mainCell: a.mainCell || ".bd",
        effect: a.effect || "left",
        autoPlay: a.autoPlay || !1,
        delayTime: a.delayTime || 200,
        interTime: a.interTime || 2500,
        defaultIndex: a.defaultIndex || 0,
        titOnClassName: a.titOnClassName || "on",
        autoPage: a.autoPage || !1,
        prevCell: a.prevCell || ".prev",
        nextCell: a.nextCell || ".next",
        pageStateCell: a.pageStateCell || ".pageState",
        pnLoop: "undefined " == a.pnLoop ? !0 : a.pnLoop,
        startFun: a.startFun || null,
        endFun: a.endFun || null,
        switchLoad: a.switchLoad || null
    },
    c = document.getElementById(b.slideCell.replace("#", ""));
    if (!c) {
        return ! 1
    }
    var d = function(a, b) {
        a = a.split(" ");
        var c = [];
        b = b || document;
        var d = [b];
        for (var e in a) {
            0 != a[e].length && c.push(a[e])
        }
        for (var e in c) {
            if (0 == d.length) {
                return ! 1
            }
            var f = [];
            for (var g in d) {
                if ("#" == c[e][0]) {
                    f.push(document.getElementById(c[e].replace("#", "")))
                } else {
                    if ("." == c[e][0]) {
                        for (var h = d[g].getElementsByTagName("*"), i = 0; i < h.length; i++) {
                            var j = h[i].className;
                            j && -1 != j.search(new RegExp("\\b" + c[e].replace(".", "") + "\\b")) && f.push(h[i])
                        }
                    } else {
                        for (var h = d[g].getElementsByTagName(c[e]), i = 0; i < h.length; i++) {
                            f.push(h[i])
                        }
                    }
                }
            }
            d = f
        }
        return 0 == d.length || d[0] == b ? !1 : d
    },
    e = function(a, b) {
        var c = document.createElement("div");
        c.innerHTML = b,
        c = c.children[0];
        var d = a.cloneNode(!0);
        return c.appendChild(d),
        a.parentNode.replaceChild(c, a),
        m = d,
        c
    },
    g = function(a, b) { ! a || !b || a.className && -1 != a.className.search(new RegExp("\\b" + b + "\\b")) || (a.className += (a.className ? " ": "") + b)
    },
    h = function(a, b) { ! a || !b || a.className && -1 == a.className.search(new RegExp("\\b" + b + "\\b")) || (a.className = a.className.replace(new RegExp("\\s*\\b" + b + "\\b", "g"), ""))
    },
    i = b.effect,
    j = d(b.prevCell, c)[0],
    k = d(b.nextCell, c)[0],
    l = d(b.pageStateCell)[0],
    m = d(b.mainCell, c)[0];
    if (!m) {
        return ! 1
    }
    var N, O, n = m.children.length,
    o = d(b.titCell, c),
    p = o ? o.length: n,
    q = b.switchLoad,
    r = parseInt(b.defaultIndex),
    s = parseInt(b.delayTime),
    t = parseInt(b.interTime),
    u = "false" == b.autoPlay || 0 == b.autoPlay ? !1 : !0,
    v = "false" == b.autoPage || 0 == b.autoPage ? !1 : !0,
    w = "false" == b.pnLoop || 0 == b.pnLoop ? !1 : !0,
    x = r,
    y = null,
    z = null,
    A = null,
    B = 0,
    C = 0,
    D = 0,
    E = 0,
    G = /hp-tablet/gi.test(navigator.appVersion),
    H = "ontouchstart" in window && !G,
    I = H ? "touchstart": "mousedown",
    J = H ? "touchmove": "",
    K = H ? "touchend": "mouseup",
    M = m.parentNode.clientWidth,
    P = n;
    if (0 == p && (p = n), v) {
        p = n,
        o = o[0],
        o.innerHTML = "";
        var Q = "";
        if (1 == b.autoPage || "true" == b.autoPage) {
            for (var R = 0; p > R; R++) {
                Q += "<li>" + (R + 1) + "</li>"
            }
        } else {
            for (var R = 0; p > R; R++) {
                Q += b.autoPage.replace("$", R + 1)
            }
        }
        o.innerHTML = Q,
        o = o.children
    }
    "leftLoop" == i && (P += 2, m.appendChild(m.children[0].cloneNode(!0)), m.insertBefore(m.children[n - 1].cloneNode(!0), m.children[0])),
    N = e(m, '<div class="tempWrap" style="overflow:hidden; position:relative;"></div>'),
    m.style.cssText = "width:" + P * M + "px;" + "position:relative;overflow:hidden;padding:0;margin:0;";
    for (var R = 0; P > R; R++) {
        m.children[R].style.cssText = "display:table-cell;vertical-align:top;width:" + M + "px"
    }
    var S = function() {
        "function" == typeof b.startFun && b.startFun(r, p)
    },
    T = function() {
        "function" == typeof b.endFun && b.endFun(r, p)
    },
    U = function(a) {
        var b = ("leftLoop" == i ? r + 1 : r) + a,
        c = function(a) {
            for (var b = m.children[a].getElementsByTagName("img"), c = 0; c < b.length; c++) {
                b[c].getAttribute(q) && (b[c].setAttribute("src", b[c].getAttribute(q)), b[c].removeAttribute(q))
            }
        };
        if (c(b), "leftLoop" == i) {
            switch (b) {
            case 0:
                c(n);
                break;
            case 1:
                c(n + 1);
                break;
            case n:
                c(0);
                break;
            case n + 1 : c(1)
            }
        }
    },
    V = function() {
        M = N.clientWidth,
        m.style.width = P * M + "px";
        for (var a = 0; P > a; a++) {
            m.children[a].style.width = M + "px"
        }
        var b = "leftLoop" == i ? r + 1 : r;
        W( - b * M, 0)
    };
    window.addEventListener("resize", V, !1);
    var W = function(a, b, c) {
        c = c ? c.style: m.style,
        c.webkitTransitionDuration = c.MozTransitionDuration = c.msTransitionDuration = c.OTransitionDuration = c.transitionDuration = b + "ms",
        c.webkitTransform = "translate(" + a + "px,0)" + "translateZ(0)",
        c.msTransform = c.MozTransform = c.OTransform = "translateX(" + a + "px)"
    },
    X = function(a) {
        switch (i) {
        case "left":
            r >= p ? r = a ? r - 1 : 0 : 0 > r && (r = a ? 0 : p - 1),
            null != q && U(0),
            W( - r * M, s),
            x = r;
            break;
        case "leftLoop":
            null != q && U(0),
            W( - (r + 1) * M, s),
            -1 == r ? (z = setTimeout(function() {
                W( - p * M, 0)
            },
            s), r = p - 1) : r == p && (z = setTimeout(function() {
                W( - M, 0)
            },
            s), r = 0),
            x = r
        }
        S(),
        A = setTimeout(function() {
            T()
        },
        s);
        for (var c = 0; p > c; c++) {
            h(o[c], b.titOnClassName),
            c == r && g(o[c], b.titOnClassName)
        }
        0 == w && (h(k, "nextStop"), h(j, "prevStop"), 0 == r ? g(j, "prevStop") : r == p - 1 && g(k, "nextStop")),
        l && (l.innerHTML = "<span>" + (r + 1) + "</span>/" + p)
    };
    if (X(), u && (y = setInterval(function() {
        r++,
        X()
    },
    t)), o) {
        for (var R = 0; p > R; R++) { !
            function() {
                var a = R;
                o[a].addEventListener("click",
                function() {
                    clearTimeout(z),
                    clearTimeout(A),
                    r = a,
                    X()
                })
            } ()
        }
    }
    k && k.addEventListener("click",
    function() { (1 == w || r != p - 1) && (clearTimeout(z), clearTimeout(A), r++, X())
    }),
    j && j.addEventListener("click",
    function() { (1 == w || 0 != r) && (clearTimeout(z), clearTimeout(A), r--, X())
    });
    var Y = function(a) {
        clearTimeout(z),
        clearTimeout(A),
        O = void 0,
        D = 0;
        var b = H ? a.touches[0] : a;
        B = b.pageX,
        C = b.pageY,
        m.addEventListener(J, Z, !1),
        m.addEventListener(K, $, !1)
    },
    Z = function(a) {
        if (!H || !(a.touches.length > 1 || a.scale && 1 !== a.scale)) {
            var b = H ? a.touches[0] : a;
            if (D = b.pageX - B, E = b.pageY - C, "undefined" == typeof O && (O = !!(O || Math.abs(D) < Math.abs(E))), !O) {
                switch (a.preventDefault(), u && clearInterval(y), i) {
                case "left":
                    (0 == r && D > 0 || r >= p - 1 && 0 > D) && (D = 0.4 * D),
                    W( - r * M + D, 0);
                    break;
                case "leftLoop":
                    W( - (r + 1) * M + D, 0)
                }
                null != q && Math.abs(D) > M / 3 && U(D > -0 ? -1 : 1)
            }
        }
    },
    $ = function(a) {
        0 != D && (a.preventDefault(), O || (Math.abs(D) > M / 10 && (D > 0 ? r--:r++), X(!0), u && (y = setInterval(function() {
            r++,
            X()
        },
        t))), m.removeEventListener(J, Z, !1), m.removeEventListener(K, $, !1))
    };
    m.addEventListener(I, Y, !1)
};
$(function() {
    $.fn.extend({
        imageZoom: function(c) {
            c = c || {};
            if (c.imageZoomBox == null) {
                alert('Parameter error, unique parameter imageZoomBox!')
            } else {
                $(c.imageZoomBox).css({
                    position: 'relative'
                });
                0 == $('div.imageMask').get().length && $(c.imageZoomBox).append('<div class=imageMask></div>');
                var a = $('.imageMask');
                a.css({
                    width: '178px',
                    height: '178px',
                    border: '1px solid #aaa',
                    background: '#fede4f',
                    opacity: '.5',
                    position: 'absolute',
                    cursor: 'move',
                    bottom: '0px',
                    'z-index': '110'
                });
                a.hide();
                $(c.imageZoomBox).bind({
                    mouseenter: function(b) {
                        a.show();
                        b = $(c.imageZoomBox).children('img');
                        var d = b.attr('src');
                        0 == $('div.imageZoom').get().length && $(this).append('<div class=imageZoom></div>');
                        0 == $('div.imageZoom').children('img').get().length && $('div.imageZoom').append('<img class=imageWapper src=' + d + '>');
                        var h = $('div.imageZoom'),
                        e = $(this).width() - 2,
                        f = $(this).height() - 2,
                        d = $(this).offset().left,
                        g = $(this).offset().top,
                        k = Math.floor($('div.imageMask').width() / 2),
                        l = Math.floor($('div.imageMask').height() / 2),
                        m = Math.floor($(this).get(0).offsetLeft - d),
                        n = Math.floor($(this).get(0).offsetTop - g),
                        p = Math.floor($(this).get(0).offsetLeft + e - d - a.width()),
                        q = Math.floor($(this).get(0).offsetTop + f - g - a.width());
                        0 <= navigator.userAgent.indexOf('Firefox') ? $('img.imageWapper').width(2.5 * e).height(2.5 * f).css({
                            position: 'absolute',
                            top: '0',
                            left: '0'
                        }) : $('img.imageWapper').width(b.width()).height(b.height()).css({
                            zoom: '1.8',
                            position: 'absolute',
                            top: '0',
                            left: '0',
                            right: '0',
                            bottom: '0'
                        });
                        b = b.css('margin');
                        b = parseInt(b.replace(/px/, ''));
                        0 != b ? $('img.imageWapper').css({
                            margin: b
                        }) : $('img.imageWapper').css({
                            margin: 0
                        });
                        h.width(e).height(f).css({
                            position: 'absolute',
                            left: e + 15,
                            top: '0',
                            border: '1px solid #ddd',
                            overflow: 'hidden',
                            'z-index': '110',
                            'background-color': '#FFFFFF'
                        });
                        $(this).bind({
                            mousemove: function(b) {
                                a.show();
                                var d = $(c.imageZoomBox).offset().top,
                                g = $(c.imageZoomBox).offset().left;
                                a.css({
                                    position: 'absolute',
                                    left: b.pageX - g - k,
                                    top: b.pageY - d - l
                                });
                                a.offset().top <= $(this).get(0).offsetTop && a.css({
                                    top: n
                                });
                                a.offset().left <= $(this).get(0).offsetLeft && a.css({
                                    left: m
                                });
                                a.offset().left >= $(this).get(0).offsetLeft + e - a.width() && a.css({
                                    left: p
                                });
                                a.offset().top >= $(this).get(0).offsetTop + f - a.height() && a.css({
                                    top: q
                                });
                                setX = Math.floor(parseInt(a.css('left').replace(/px/, '')));
                                setY = Math.floor(parseInt(a.css('top').replace(/px/, '')));
                                0 <= navigator.userAgent.indexOf('Firefox') ? h.children('img').css({
                                    top: 2 * -setY,
                                    left: 2 * -setX
                                }) : h.children('img').css({
                                    top: -setY / 1.23,
                                    left: -setX / 1.23
                                })
                            },
                            mouseout: function() {
                                a.hide()
                            }
                        });
                        a.mouseout(function(b) {
                            a.hide();
                            b.pageX >= a.offset().left || b.pageX >= a.offset().left + a.width() || b.pageY >= a.offset().top || b.pageY >= a.offset().top + a.height() ? $('div.imageZoom').remove() && $('div.imageMask').hide() && $('.imageWapper').removeAttr('src') : console.log('\u5361\u6b7b\uff01')
                        })
                    }
                })
            }
        },
        FloorListen: function(a) {
            a = a || {};
            d = document;
            main = $(a.parent);
            getLayer = main.find('[floor]');
            length = getLayer.length;
            getfloorUl = $(a.floorId);
            a = parseInt(getLayer.css('margin-top').replace(/px/, ''));
            var h = parseInt(getLayer.css('margin-bottom').replace(/px/, '')),
            k = parseInt(getLayer.css('padding-top').replace(/px/, '')),
            l = parseInt(getLayer.css('padding-bottom').replace(/px/, '')),
            e = a + h + k + l,
            f = $(window).height();
            for (a = 0; a < length; a++) getfloorUl.append('<li>');
            var b = [];
            for (a = 0; a < length; a++) b[a] = Math.floor(getLayer.eq(a).get(0).offsetTop);
            var g = [];
            for (a = 0; a < length; a++) g[a] = Math.floor(b[a] - f / 2 + getLayer.height() / 2 - e);
            var c = 0;
            $(window).scroll(function() {
                for (var a = 0; a < length; a++) $(window).scrollTop() >= g[a] ? (c = a, getfloorUl.find('li').eq(c).addClass('on').siblings().removeClass('on')) : c = 0
            });
            getfloorUl.find('li').on('click',
            function() {
                thisId = $(this).index();
                var a = b[thisId] - f / 2 + getLayer.height() / 2 - e;
                $('html,body').animate({
                    scrollTop: a
                },
                120)
            })
        },
        bannerFade: function(e, f) {
            var g = null,
            o = 0,
            f = f || {};
            $(e).each(function() {
                ms = $(this).find(f.mainCell),
                as = $(this).find(f.titCell),
                ab = $(this).find(f.colorCell),
                p = $(this).find(f.prev),
                n = $(this).find(f.next),
                h = f.hasColor,
                l = ms.children('li').length,
                s = f.speed * 1e3 || 5e3;
                init();
                if (h) {
                    for (var i = 0; i < l; i++) {
                        ab.append('<li class=Fade_Background_Color' + (i + 1) + '></li>') && as.append('<li>' + (i + 1) + '</li>')
                    };
                    ab.children('li').height(ab.height()).width(ab.width());
                    fd(ab)
                } else {
                    cs(as)
                };
                $(window).resize(function() {
                    ab.children('li').width(Math.ceil($(window).width()));
                    if (ab.children('li').width() <= ms.width()) {
                        ab.children('li').width(ms.width())
                    }
                });
                as.children('li:first').addClass('on');
                fd(ms);
                as.find('li').on('click',
                function() {
                    clearInterval(g);
                    a = $(this).index();
                    o = a;
                    cf(o);
                    init()
                });
                ms.hover(function() {
                    clearInterval(g)
                },
                function() {
                    init()
                });
                n.on('click',
                function() {
                    clearInterval(g);
                    Main();
                    init()
                });
                p.on('click',
                function() {
                    clearInterval(g);
                    o--;
                    if (o == -1) {
                        o = ms.children('li').length - 1
                    }
                    init();
                    cf(o)
                });
                function Main() { (o == ms.children('li').length - 1) ? o = 0 : o += 1;
                    cf(o)
                };
                if (!h == true) {
                    function cf(a) {
                        sf(ms.children('li'), 300, a)
                    }
                } else {
                    function cf(a) {
                        sf(ab.children('li'), 300, a);
                        sf(ms.children('li'), 300, a)
                    }
                }
                function sf(a, b, c) {
                    a.eq(c).animate({
                        opacity: 1
                    },
                    b).css({
                        'z-index': '1'
                    }).siblings().animate({
                        opacity: 0
                    },
                    b).css({
                        'z-index': '0'
                    });
                    ck(c)
                }
                function init() {
                    g = setInterval(function() {
                        Main()
                    },
                    s)
                };
                function fd(a) {
                    a.children('li:first').css({
                        'position': 'absolute',
                        'z-index': '1'
                    }) && a.children('li:not(:first)').css({
                        'position': 'absolute',
                        'z-index': '0'
                    })
                };
                function cs(a) {
                    for (var i = 0; i < l; i++) {
                        a.append('<li>' + (i + 1) + '</li>')
                    }
                }
                function ck(a) {
                    as.children('li').removeClass('on') && as.children('li').eq(a).addClass('on')
                }
            })
        },
        bannerMove: function(e, f) {
            var g = null,
            o = 0;
            $(e).each(function() {
                ms = $(this).find(f.mainCell),
                as = $(this).find(f.titCell),
                p = $(this).find(f.prev),
                n = $(this).find(f.next),
                l = ms.children('li').length;
                s = f.speed * 1e3 || 5e3;
                init();
                cs(as);
                as.children('li:first').addClass('on');
                w = $(this).find('[wrapper]').parent();
                gw = w.width();
                gh = w.height();
                ms.width(gw * l).height(gh);
                ms.children('li').css({
                    'float': 'left'
                }).width(gw).height(gh);
                as.children('li').on('click',
                function() {
                    clearInterval(g);
                    a = $(this).index();
                    o = a;
                    mo(o);
                    init()
                });
                n.on('click',
                function() {
                    clearInterval(g);
                    Main();
                    init()
                });
                p.on('click',
                function() {
                    clearInterval(g);
                    o--;
                    if (o == -1) {
                        o = ms.children('li').length - 1
                    }
                    init();
                    mo(o)
                });
                function Main() { (o == ms.children('li').length - 1) ? o = 0 : o += 1;
                    mo(o)
                };
                ms.hover(function() {
                    clearInterval(g)
                },
                function() {
                    init()
                });
                function mo(a) {
                    ms.animate({
                        marginLeft: -ms.children('li').width() * a + 'px'
                    },
                    400 || linear);
                    ck(a)
                }
                function init() {
                    g = setInterval(function() {
                        Main()
                    },
                    s)
                }
                function ck(a) {
                    as.children('li').removeClass('on') && as.children('li').eq(a).addClass('on')
                };
                function cs(a) {
                    for (var i = 0; i < l; i++) {
                        a.append('<li>' + (i + 1) + '</li>')
                    }
                }
            })
        },
        disableBtn: function(a) {
            a = a || {},
            t = null,
            o = $(a.btn),
            g = o.val();
            o.on('click',
            function() {
                clearInterval(t);
                c = a.cont;
                t = setInterval(function() {
                    c--;
                    o.val(c + 's' + a.afterVal).attr('disabled', 'true');
                    if (c <= 0) {
                        clearInterval(t);
                        o.val(g).removeAttr('disabled')
                    }
                },
                1e3)
            })
        },
        dragBle: function(a) {
            a = a || {},
            m = $(a.main),
            w = $(a.parent);
            m.on('mousedown',
            function(e) {
                cX = e.pageX - m.get(0).offsetLeft;
                cY = e.pageY - m.get(0).offsetTop;
                d = true,
                sw = w.width(),
                sh = w.height();
                $(document).bind({
                    'mousemove': function(e) {
                        if (d) {
                            iX = e.pageX - cX;
                            iY = e.pageY - cY;
                            document.title = iX;
                            if (iX < w.get(0).offsetLeft) {
                                iX = w.get(0).offsetLeft
                            }
                            if (iY < w.get(0).offsetTop) {
                                iY = w.get(0).offsetTop
                            }
                            if (iX > w.get(0).offsetLeft + w.width() - m.width()) {
                                iX = w.get(0).offsetLeft + w.width() - m.width()
                            }
                            if (iY > w.get(0).offsetTop + w.height() - m.height()) {
                                iY = w.get(0).offsetTop + w.height() - m.height()
                            }
                            m.css({
                                left: Math.floor(iX),
                                top: Math.floor(iY),
                                'z-index': 1000
                            })
                        }
                    },
                    'mouseup': function(e) {
                        d = false
                    }
                })
            })
        },
        mWarnTimer: null,
        mWarn: function(a) {
            a = a || {};
            clearInterval(this.mWarnTimer);
            $(a.alertObj).show().addClass(a.class);
            this.mWarnTimer = setInterval(function() {
                $(a.alertObj).hide().removeClass(a.class);
            },
            1500);
            $(a.alertObj).html(a.text);
        },
        rolling: function(a) {
            a = a || {};
            var h = $(window).height();
            var f = $(a.effect);
            var l = f.length;
            var t = [];
            var r = a.repeat;
            var d = a.equal;
            if (f.eq(0).get(0).offsetTop < h) {
                return null
            } else {
                for (var i = 0; i < l; i++) {
                    t[i] = f.eq(i).get(0).offsetTop
                }
                $(window).scroll(function() {
                    for (var b = 0; b < l; b++) {
                        var c = t[b] - $(window).scrollTop();
                        if (c <= h) { (d) ? ad(f, b, a.className, '', a.child, a.childClassName) : ad(f, b, a.className, '_' + (b + 1), a.child, a.childClassName)
                        } else {
                            if (r) { (d) ? dd(f, b, a.className, '', a.child, a.childClassName) : dd(f, b, a.className, '_' + (b + 1), a.child, a.childClassName)
                            } else {
                                return null
                            }
                        }
                    }
                })
            }
            function ad(a, b, c, d, e, f) {
                a.eq(b).addClass(c + d) && a.eq(b).find(e).addClass(f + d)
            };
            function dd(a, b, c, d, e, f) {
                a.eq(b).removeClass(c + d) && a.eq(b).find(e).removeClass(f + d)
            }
        },
        last: function() {
            console.log('$.fn.last')
        }
    })
});
var timer2 = null;

function mWarn(a) {
    clearInterval(timer2);
    $('#alert').show().addClass('Alert_bounceUp');
    timer2 = setInterval(function() {
        $('#alert').hide().removeClass('Alert_bounceUp');
    },
    1500);
    $('#alert').html(a);
}
